﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using Bornander.UI.ListItems;
using Microsoft.WindowsMobile.PocketOutlook;
using Application = System.Windows.Forms.Application;

namespace Bornander.UI.Test
{
    public partial class ApplicationForm : Form
    {
        
        private Dictionary<MenuScreen.ListType, SmoothListbox> listBoxes = new Dictionary<MenuScreen.ListType, SmoothListbox>();
        
         

        public ApplicationForm()
        {
            InitializeComponent();
 
            listBoxes[MenuScreen.ListType.UserList] = new SmoothListbox(); 
            this.LoadUserListContent(listBoxes[MenuScreen.ListType.UserList]);

            foreach (SmoothListbox smoothListBox in listBoxes.Values)
            {
                smoothListBox.Visible = true;
                smoothListBox.Dock = DockStyle.Fill;
                smoothListBox.BackColor = Color.Black;
                this.Controls.Add(smoothListBox);
            }
            
        }

        private void HandleListSelected(MenuScreen.ListType listType, bool multipleSelectionsEnabled, bool explicitUnselectEnabled)
        {
            SmoothListbox smoothListBox = listBoxes[listType];
            smoothListBox.Reset();
            smoothListBox.MultiSelectEnabled = multipleSelectionsEnabled;
            smoothListBox.UnselectEnabled = explicitUnselectEnabled;
            smoothListBox.Visible = true; 
        }

        private void MenuItemExitClicked(object sender, EventArgs e)
        {
            
        }

        private  void LoadUserListContent(SmoothListbox smoothListbox)
        {
            List<string[]> list = SIMContactManage.GetSIMContactList();

            string[] str;
            for (int i = 0; i < list.Count; i++)
            {
                str = list[i];
                smoothListbox.AddItem(new UserList(Bornander.UI.Test.Properties.Resources.mHead, str[0], str[1], "2", "2"));
            }

            OutlookSession myoutlookSession = new OutlookSession(); 
            foreach (Contact c in myoutlookSession.Contacts.Items)
            {
                smoothListbox.AddItem(new UserList(Bornander.UI.Test.Properties.Resources.mHead, c.FileAs, c.MobileTelephoneNumber, "2", "2"));
            }
        }

        private void menuItem4_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        
         
    }
}